def print1():
    x = "There are %d types of people." % 9000
    binary = "binary"
    do_not = 21.213244
    y = "Those who know %s and those who %f" % (binary, do_not)
    print x
    print y

    print "I said: %r." % x
    print "I also said: '%s'." % y

    hilarious = False
    joke_evaluation = "Isn't that joke so funny?! %r"

    print joke_evaluation % hilarious

    w = "This is the left side of..."
    e = "a string with a right side."

    print w + e


def print2():
    print "Mary had a little lamb."
    print "Its fleece was white as %s." % 'snow'
    print "And everywhere that Mary went."
    print "Ah." * 20  # what'd that do?

    end1 = "C"
    end2 = "h"
    end3 = "e"
    end4 = "e"
    end5 = "s"
    end6 = "e"
    end7 = "B"
    end8 = "u"
    end9 = "r"
    end10 = "g"
    end11 = "e"
    end12 = "r"

    # watch that comma at the end.  try removing it to see what happens
    print end1 + end2 + end3 + end4 + end5 + end6,
    print end7 + end8 + end9 + end10 + end11 + end12
    print """
            There's something going on here.
            With the three double-quotes.
            We'll be able to type as much as we like.
            Even 4 lines if we want, or 5, or 6.
    """
    days = "Mon Tue Wed Thu Fri Sat Sun"
    months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"

    print "Here are the days: ", days
    print "Here are the months: ", months


def prompt():
    age = raw_input("How old are you? ")
    height = raw_input("How tall are you? ")
    weight = raw_input("How much do you weigh? ")

    print "So, you're %r old, %r tall and %r heavy." % (age, height, weight)


def dict2():
    # create a mapping of state to abbreviation
    states = {
        'Oregon': 'OR',
        'Florida': 'FL',
        'California': 'CA',
        'New York': 'NY',
        'Michigan': 'MI'
    }

    # create a basic set of states and some cities in them
    cities = {
        'CA': 'San Francisco',
        'MI': 'Detroit',
        'FL': 'Jacksonville'
    }

    # add some more cities
    cities['NY'] = 'New York'
    cities['OR'] = 'Portland'

    # print out some cities
    print '-' * 10
    print "NY State has: ", cities['NY']
    print "OR State has: ", cities['OR']

    # print some states
    print '-' * 10
    print "Michigan's abbreviation is: ", states['Michigan']
    print "Florida's abbreviation is: ", states['Florida']

    # do it by using the state then cities dict
    print '-' * 10
    print "Michigan has: ", cities[states['Michigan']]
    print "Florida has: ", cities[states['Florida']]

    # print every state abbreviation
    print '-' * 10
    for state, abbrev in states.items():
        print "%s is abbreviated %s" % (state, abbrev)

    # print every city in state
    print '-' * 10
    for abbrev, city in cities.items():
        print "%s has the city %s" % (abbrev, city)

    # now do both at the same time
    print '-' * 10
    for state, abbrev in states.items():
        print "%s state is abbreviated %s and has city %s" % (
            state, abbrev, cities[abbrev])

    print '-' * 10
    # safely get a abbreviation by state that might not be there
    state = states.get('Texas')

    if not state:
        print "Sorry, no Texas."

    # get a city with a default value
    city = cities.get('TX', 'Does Not Exist')
    print "The city for the state 'TX' is: %s" % city


if __name__ == '__main__':
    # print1()
    # print2()
    # prompt()
    dict2()
